package JD;

import java.util.Scanner;

public class Main_0909_1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        String line=cin.nextLine();
        char[] cs=line.toCharArray();
        int n=line.length();
        int res=0;
        for(int i=0;i<n-1;i++){
            //找到连续的相同的个数
            int count=1;
            while (i<n-1&&cs[i]==cs[i+1]){
                count++;i++;
            }
            if (count!=1){
                res+=(count-2)/3+1;
            }
        }
        System.out.println(res);
    }
}
